/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app.gnucash.client;

import app.gnucash.client.mvc.AppController;
import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

/**
 * Main entry point.
 *
 * @author cc
 */
public class MainEntryPoint implements EntryPoint {

    public static final String SERVICE = "thesisservice";
    public static final String COMPILE_SERVICE = "compileservice";
    public static final String PAPER_SERVICE = "paperservice";

    /**
     * Creates a new instance of MainEntryPoint
     */
    public MainEntryPoint() {
    }

    /** 
     * The entry point method, called automatically by loading a module
     * that declares an implementing class as an entry-point
     */
    public void onModuleLoad() {
        thesisServiceAsync service = (thesisServiceAsync) GWT.create(thesisService.class);
        ServiceDefTarget endpoint = (ServiceDefTarget) service;
        String moduleRelativeURL = SERVICE;
        endpoint.setServiceEntryPoint(moduleRelativeURL);
        Registry.register(SERVICE, service);

//        GxtForm gxt = new GxtForm();
//        RootPanel.get().add(gxt);
//
         /**
         * Events Maps
         */
        // Events in AppController
        Registry.register("AppInitError", AppEvents.Error);
        Registry.register("AppInitSuccess", AppEvents.Navthesis);

        Dispatcher dispatcher = Dispatcher.get();
        dispatcher.addController(new AppController());
//        dispatcher.addController(new thesisController());
//        dispatcher.addController(new TaskController());
//        dispatcher.addController(new AppControllerTest());
        //dispatcher.dispatch(AppEvents.Test);
        dispatcher.dispatch(AppEvents.Login);
        GXT.hideLoadingPanel("loading");
    }
}
